Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trace: use standard POSIX header for basename() #6

Merged
merged 1 commit into from
Apr 2, 2024

Conversation

guidosarducci
Copy link
Contributor

@guidosarducci guidosarducci commented Mar 6, 2024

The musl libc only implements POSIX basename() but provided a GNU header kludge in <string.h>, which is removed in musl 1.2.5 [1]. Use the standard <libgen.h> header to avoid compilation errors like:

trace/trace.c: In function 'main':
trace/trace.c:435:64: error: implicit declaration of function 'basename'; did you mean 'rename'? [-Werror=implicit-function-declaration]
  435 | if (asprintf(&json, "/tmp/%s.%u.json", basename(*argv), child) < 0)
      |                                        ^~~~~~~~
      |                                        rename
cc1: all warnings being treated as errors

Link 1: https://git.musl-libc.org/cgit/musl/log/?qt=grep&q=basename

@blogic This change is related to openwrt/openwrt#14802 and was tested therein.

@guidosarducci
Copy link
Contributor Author

@dangowrt Would appreciate if you have a chance to look at this. Thanks...

@Ansuel
Copy link
Member

Ansuel commented Mar 8, 2024

@guidosarducci i searched a bit on the differences and there are a few but considering the following case maybe it's ok...

the main difference is that posix variant can modify the passed arg (while GNU one can't)

But I assume in the following context it's not a problem since argc is not used in the code after basename is called.

@dangowrt
Copy link
Member

dangowrt commented Mar 8, 2024 via email

@guidosarducci
Copy link
Contributor Author

@guidosarducci i searched a bit on the differences and there are a few but considering the following case maybe it's ok...

the main difference is that posix variant can modify the passed arg (while GNU one can't)

But I assume in the following context it's not a problem since argc is not used in the code after basename is called.

Code was written under the assumption that basename() modifies the argument.

Right, I concluded the same thing while reviewing, so thought this should be OK. Thanks for looking.

@guidosarducci
Copy link
Contributor Author

@dangowrt @Ansuel Are there any changes you'd like to see or is this OK as is?

@guidosarducci
Copy link
Contributor Author

I see that CI checks were just added for procd are are now flagging errors, however the failure looks to be internal and unrelated to this PR. This is a trivial change, has been tested and reviewed, and is needed before a toolchain update to musl 1.2.5.

At the moment I have multiple PRs blocked by unrelated CI failures or shortcomings, sitting for several weeks total, with no response from members as to workarounds or fixes. See also openwrt/ubox#4 for example.

Any suggestions on how best to proceed @Ansuel @dangowrt @aparcar @ynezz ?

@Ansuel
Copy link
Member

Ansuel commented Mar 30, 2024 via email

@ynezz
Copy link
Member

ynezz commented Mar 30, 2024

I see that CI checks were just added for procd are are now flagging errors

Indeed, GH CI is really strange, since it seems, that one can't test addition of the CI bits, thus due to that broken pull request was merged, still it should be either reverted or GH actions disabled until this is fixed.

however the failure looks to be internal and unrelated to this PR.

Correct, sorry about that.

@dangowrt
Copy link
Member

Please make your branch writable for maintainers so we can rebase it before merging. Or rebase on top of current procd git HEAD yourself and force-push.

The musl libc only implements POSIX basename() but provided a GNU header
kludge in <string.h>, which was removed in musl 1.2.5 [1]. Use the standard
<libgen.h> header to avoid compilation errors like:

trace/trace.c: In function 'main':
trace/trace.c:435:64: error: implicit declaration of function 'basename';
did you mean 'rename'? [-Werror=implicit-function-declaration]
  435 | if (asprintf(&json, "/tmp/%s.%u.json", basename(*argv), child) < 0)
      |                                        ^~~~~~~~
      |                                        rename
cc1: all warnings being treated as errors

Link 1: https://git.musl-libc.org/cgit/musl/log/?qt=grep&q=basename

Signed-off-by: Tony Ambardar <[email protected]>
@guidosarducci
Copy link
Contributor Author

Please make your branch writable for maintainers so we can rebase it before merging. Or rebase on top of current procd git HEAD yourself and force-push.

@dangowrt Thanks, I've done both yesterday.

@openwrt-bot openwrt-bot merged commit 946552a into openwrt:master Apr 2, 2024
1 check failed
@robimarko
Copy link

Thanks! Rebased on top of master and merged!

@guidosarducci
Copy link
Contributor Author

Thanks, Robert.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants